const {DataTypes} = require("sequelize");

const seq = require("../db/seq");
const Record = require("./record.model");

// 创建模型(Model zd_user -> 表 zd_users)
const Notice = seq.define(
    "notice",
    {
        // id 会被sequelize自动创建, 管理
        notice_title: {
            type: DataTypes.STRING,
            allowNull: false,
            comment: "公告标题",
        },
        notice_content: {
            type: DataTypes.TEXT,
            allowNull: false,
            comment: "公告内容",
        },
        record_id: {
            type: DataTypes.INTEGER,
            allowNull: false,
            comment: "记录id,存储点赞、浏览数据",
        },
    },
    {
        paranoid: true,
    }
);
Notice.belongsTo(Record, {
    foreignKey: "record_id",
    as: "record_info",
});
// 强制同步数据库(创建数据表)
// Notice.sync({ force: true });

module.exports = Notice;
